﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Voorwaarden : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            FillDropdownCategory();
            FillDropdownMerk();
            FillDropdownProduct();
            FillDropdownEigenschappen();
        }
    }

    private void FillDropdownMerk()
    {
        DropDownListMerken.DataSource = SqlDataSourceMerken;
        DropDownListMerken.DataTextField = "merknaam";
        DropDownListMerken.DataValueField = "idMerk";
        DropDownListMerken.DataBind();
        DropDownListMerken.Items.Insert(0, new ListItem("--Selecteer een merk--","0"));
    }
    private void FillDropdownEigenschappen()
    {
        if (DropDownListProducten.SelectedIndex > 0)
        {
            DropDownListEigenschappen.DataSource = SqlDataSourceEigenschappen;
            DropDownListEigenschappen.DataTextField = "waarde";
            DropDownListEigenschappen.DataValueField = "idSpecificatieNamen";
            DropDownListEigenschappen.DataBind();
            DropDownListEigenschappen.Items.Insert(0, new ListItem("--Selecteer een eigenschap--", "0"));
        }
        else
        {
            DropDownListEigenschappen.DataSource = SqlDataSourceAlleEigenschappen;
            DropDownListEigenschappen.DataTextField = "waarde";
            DropDownListEigenschappen.DataValueField = "waarde";
            DropDownListEigenschappen.DataBind();
            DropDownListEigenschappen.Items.Insert(0, new ListItem("--Selecteer een eigenschap--", "0"));
        }

    }

    protected void FillDropdownCategory()
    {
        DropDownListCategory.DataSource = SqlDataSourceCategorie;
        DropDownListCategory.DataTextField = "waarde";
        DropDownListCategory.DataValueField = "idSpecificatieNamen";
        DropDownListCategory.DataBind();
        DropDownListCategory.Items.Insert(0, new ListItem("--Selecteer een categorie--", "0"));
    }

    protected void FillDropdownProduct()
    {
        if (DropDownListCategory.SelectedIndex > 0)
        {
            DropDownListProducten.DataSource = SqlDataSourceProductenCategorie;
            DropDownListProducten.DataTextField = "naam";
            DropDownListProducten.DataValueField = "artikelNr";
            DropDownListProducten.DataBind();
            DropDownListProducten.Items.Insert(0, new ListItem("--Selecteer een product--", "0"));
        }
        else
        {
            DropDownListProducten.DataSource = SqlDataSourceAlleProducten;
            DropDownListProducten.DataTextField = "naam";
            DropDownListProducten.DataValueField = "artikelNr";
            DropDownListProducten.DataBind();
            DropDownListProducten.Items.Insert(0, new ListItem("--Selecteer een product--", "0"));
        }
        FillDropdownEigenschappen();

    }


    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
        //DropDownListProducten.DataBind();
        //DropDownListEigenschappen.DataBind();
        //DropDownListWaarde.DataBind();
    }
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        if (Panel1.Visible == false)
            Panel1.Visible = true;
    }
    protected void ButtonVerwijder_Click(object sender, EventArgs e)
    {
     
    }

    protected void DropDownList8_SelectedIndexChanged(object sender, EventArgs e)
    {
        //if (((DropDownList)sender).SelectedIndex > 0)
        //    TextBoxAantal.Visible = true;
        //else
        //    TextBoxAantal.Visible = false;
    }
    
  
    protected void DropDownListProducten_SelectedIndexChanged(object sender, EventArgs e)
    {

        FillDropdownEigenschappen();
        
        //DropDownListEigenschap2.DataBind();
    }

    protected void DropDownListEigenschappen_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownListWaarde.DataBind();
    }
    protected void DropDownListCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        FillDropdownProduct();
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (((DropDownList)sender).SelectedValue == "product")
        {
            SetPanelVisible(false);
            PanelProduct.Visible = true;
        }
        else if (((DropDownList)sender).SelectedValue == "betaal")
        {
            SetPanelVisible(false);
            PanelBetaalmethode.Visible = true;
        }
        if (((DropDownList)sender).SelectedValue == "verzend")
        {
            SetPanelVisible(false);
            PanelVerzendFormule.Visible = true;
        }
       // else
       
            
    }
    private void SetPanelVisible(bool visible)
    {
        PanelProduct.Visible = visible;
        PanelBetaalmethode.Visible = visible;
        PanelVerzendFormule.Visible = visible;
    }
    protected void DropDownList14_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(((DropDownList)sender).SelectedValue=="alle")
        {
            TextBoxAantal.Visible=false;
            DropDownListAantal.Visible=false;
        }
        else
        {
            TextBoxAantal.Visible = true;
            DropDownListAantal.Visible = true;
        }

    }
}
